package com.example.player.presentation.fragment;

import android.app.Dialog;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.DialogFragment;

import com.example.player.R;
import com.example.player.domain.entity.Song;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
/**
 * 歌曲详细信息
 * */
public class SongInfoDialog extends BottomSheetDialogFragment {

    private static final String ARG_SONG_INFO = "song_info";
    private Song songInfo;
    public SongInfoDialog(Song song){
        super();
        this.songInfo=song;
    }
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater,
                             @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
        // 加载布局文件
        View view = inflater.inflate(R.layout.dialog_song_info, container, false);

        // 初始化视图
        TextView tvSongTitle = view.findViewById(R.id.tvSongTitle);
        TextView tvArtist = view.findViewById(R.id.tvArtist);
        TextView tvAlbum = view.findViewById(R.id.tvAlbum);
        TextView tvDuration = view.findViewById(R.id.tvDuration);
        TextView tvYear = view.findViewById(R.id.tvYear);
        TextView tvSize = view.findViewById(R.id.tvSize);
        TextView tvType = view.findViewById(R.id.tvType);
        TextView tvBitrate = view.findViewById(R.id.tvBitrate);
        TextView tvLocation = view.findViewById(R.id.tvLocation);

        // 设置歌曲信息
        if (songInfo != null) {
            tvSongTitle.setText(songInfo.getTitle());
            tvArtist.setText(songInfo.getArtist());
            // 以下字段请确保在Song类中存在对应get方法
            // tvAlbum.setText(songInfo.getAlbum());
            tvDuration.setText(songInfo.getDuration());
            // tvYear.setText(songInfo.getYear());
            tvSize.setText(songInfo.getSize());
            tvType.setText(songInfo.getType());
            // tvBitrate.setText(songInfo.getBitrate());
            tvLocation.setText(songInfo.getPath());
        }

        return view;
    }


}